/**
 * Created by jinhongglin on 15-11-17.
 */
app.controller("help_order_meal_controller",function($scope,$location){
    $scope.to_person = function(){
        $location.path('/person.html')
    }
    $scope.to_restaurant = function(){
        $location.path("/restaurant.html")
    }
    $scope.to_set_meal = function(){
        $location.path("/set_meal.html")
    }
    $scope.to_home = function(){
        $location.path("/")
    }
    get_meal_information($scope)
    //var all_information = {};
    var total_information = judge_contain(localStorage.getItem("total_informations"))
    var all_information = add_information_to_localstorage($scope)
    total_information.push(all_information)
    judge_text_contain_value();
    judge_restaurant()
    $scope.clear_storage = function(){
        //doReset()
        delete_localstorage(localStorage)
        delete_text($scope)
        var set_meal_information = JSON.stringify(total_information);
        localStorage.total_informations = set_meal_information;
        //location.reload()
    }
});
function get_meal_information ($scope){
    $scope.name= localStorage.getItem("person_name")
    $scope.restaurant_name = localStorage.getItem("restaurant_name")
    $scope.meal_price=localStorage.getItem("meal_price")
    $scope.meal_name = localStorage.getItem("meal_name")
}
function add_information_to_localstorage($scope){
    var all_information ={};
    all_information['set_meal_person_name'] =  $scope.name;
    all_information['set_meal_restaurant_name'] = $scope.restaurant_name;
    all_information['set_meal_name'] = $scope.meal_name;
    all_information['set_meal_price'] = $scope.meal_price;
    return all_information;
}
function delete_localstorage(localStorage){
    localStorage.removeItem('person_name')
    localStorage.removeItem('restaurant_name')
    localStorage.removeItem('meal_name')
    localStorage.removeItem('meal_price')

}
function delete_text($scope){
    $scope.name = "";
    $scope.restaurant_name = "";
    $scope.meal_name ="";


}
